﻿<UserControl x:Class="YALV.View.Components.PropertiesView"
    
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:converters="clr-namespace:YalvLib.Common.Converters;assembly=YalvLib"
    xmlns:cult="clr-namespace:YalvLib.ViewModel;assembly=YALVLib"
    xmlns:Properties="clr-namespace:YalvLib.Strings;assembly=YALVLib"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    mc:Ignorable="d" 
    d:DesignHeight="450" d:DesignWidth="300"
    >
  <UserControl.Resources>
    <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
    <converters:LevelToSolidColorConverter x:Key="LevelToSolidColorConverter" />
    <converters:StringEmptyToVisibilityConverter x:Key="StringEmptyToVisibilityConverter" />
    <converters:BoolToOppositeVisibilityConverter x:Key="BoolToOppositeVisibilityConverter" />
  </UserControl.Resources>
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <!-- LogItem properties -->
    <ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Auto"
                               VerticalScrollBarVisibility="Auto">
      <Grid>
        <Grid.Resources>
          <Style x:Key="TextBoxLabelStyle" TargetType="{x:Type TextBox}">
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="IsReadOnly" Value="True" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="Foreground" Value="{DynamicResource WindowText}" />
            <Setter Property="BorderBrush" Value="{x:Null}" />

            <!-- http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/63696841-0358-4f7a-abe1-e6062518e3d6
                xmlns:behav="clr-namespace:ModernYalv.Behaviour"
            <Setter Property="behav:MergeStyleBehaviour.AutoMergeStyle" Value="True"/>
            -->

            <Setter Property="Template">
              <Setter.Value>
                <ControlTemplate TargetType="TextBox">
                  <Border Name="Bd" BorderThickness="{TemplateBinding BorderThickness}" 
                                             BorderBrush="{TemplateBinding BorderBrush}" 
                                             Background="{TemplateBinding Background}" 
                                             SnapsToDevicePixels="true">
                    <ScrollViewer Name="PART_ContentHost" Background="{TemplateBinding Background}" 
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                  </Border>
                  <ControlTemplate.Triggers>
                    <Trigger Property="IsEnabled" Value="False">
                      <Setter Value="Transparent" Property="Background" />
                      <!-- Setter Value="{StaticResource DisabledForegroundBrush}" Property="Foreground" / -->
                      <Setter TargetName="PART_ContentHost" Property="Background" Value="Transparent"/>
                    </Trigger>
                  </ControlTemplate.Triggers>
                </ControlTemplate>
              </Setter.Value>
            </Setter>
          </Style>
        </Grid.Resources>
          <Grid.RowDefinitions>
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
          <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto" />
          <ColumnDefinition Width="Auto" />
          <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Column="0"
                   Text="{x:Static Properties:Resources.MainWindow_DetailsBox_ItemId_Text}"
               VerticalAlignment="Center" HorizontalAlignment="Right"/>

        <Grid HorizontalAlignment="Stretch" Grid.Column="2">
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
          </Grid.ColumnDefinitions>

          <TextBox HorizontalAlignment="Left" HorizontalContentAlignment="Left" VerticalContentAlignment="Center"
                   Text="{Binding Path=LogEntryRows.GoToLogItemId, UpdateSourceTrigger=PropertyChanged}"
                   Width="75"
                   Grid.Column="0" />

          <TextBox Text="{Binding Path=LogEntryRows.SelectedLogItem.Level, Mode=OneWay}"
                   ToolTip="{x:Static Properties:Resources.MainWindow_DetailsBox_Level_Text}"
                   Grid.Column="1" Style="{StaticResource TextBoxLabelStyle}"
                   VerticalAlignment="Center" HorizontalAlignment="Left" />

          <Border Height="11" Grid.Column="2"
                  Margin="2,0,0,0"
                  Width="11"
                  Background="{Binding Path=LogEntryRows.SelectedLogItem.LevelIndex, Mode=OneWay, Converter={StaticResource LevelToSolidColorConverter}}"
                  BorderBrush="{StaticResource BorderColor}"
                  BorderThickness="1"
                  CornerRadius="6"
                  VerticalAlignment="Center"
                  HorizontalAlignment="Left"
                  Visibility="{Binding Path=LogEntryRows.SelectedLogItem.Level, Mode=OneWay, Converter={StaticResource StringEmptyToVisibilityConverter}, FallbackValue=Collapsed}" />
        </Grid>

        <TextBlock Grid.Column="0" Grid.Row="1"
                   Text="{x:Static Properties:Resources.MainWindow_DetailsBox_Logger_Text}"
                   VerticalAlignment="Center" HorizontalAlignment="Right"/>

        <TextBox Text="{Binding Path=LogEntryRows.SelectedLogItem.Logger, Mode=OneWay}" Style="{StaticResource TextBoxLabelStyle}"
                 Grid.Column="2" Grid.Row="1" />

        <TextBlock Text="{x:Static Properties:Resources.MainWindow_DetailsBox_TimeStamp_Text}"
               VerticalAlignment="Center" HorizontalAlignment="Right"
               Grid.Column="0" Grid.Row="2" />
        <TextBox  Style="{StaticResource TextBoxLabelStyle}"
                  Grid.Column="2" Grid.Row="2">
          <TextBox.Text>
            <Binding Mode="OneWay"
                     StringFormat="{x:Static Properties:Resources.MainWindow_FullDateTimeFormatWithMilliseconds}"
                     ConverterCulture="{x:Static cult:ResolveCultures.ResolvedCulture}"
                     Path="LogEntryRows.SelectedLogItem.TimeStamp" />
            </TextBox.Text>
        </TextBox>


        <TextBlock Grid.Column="0" Grid.Row="3"
                   Text="Δ t:"
                   ToolTip="{x:Static Properties:Resources.MainWindow_DetailsBox_TimeDiff_Text}"
                   VerticalAlignment="Center" HorizontalAlignment="Right"/>

        <TextBox Text="{Binding Path=LogEntryRows.SelectedLogItem.Delta, Mode=OneWay}"
                 ToolTip="{x:Static Properties:Resources.MainWindow_DetailsBox_TimeDiff_Text}"
                 Style="{StaticResource TextBoxLabelStyle}"
                 Grid.Column="2" Grid.Row="3" />

        <TextBlock Grid.Column="0" Grid.Row="4"
	                 Text="{x:Static Properties:Resources.MainWindow_DetailsBox_MachineName_Text}"
	                 VerticalAlignment="Center" HorizontalAlignment="Right"/>

        <TextBox Text="{Binding Path=LogEntryRows.SelectedLogItem.MachineName, Mode=OneWay}"
	         Style="{StaticResource TextBoxLabelStyle}"
	         Grid.Column="2" Grid.Row="4" />


        <TextBlock Grid.Column="0" Grid.Row="5"
	                 Text="{x:Static Properties:Resources.MainWindow_DetailsBox_HostName_Text}"
	                 VerticalAlignment="Center" HorizontalAlignment="Right"/>

        <TextBox Text="{Binding Path=LogEntryRows.SelectedLogItem.HostName, Mode=OneWay}"
	         Style="{StaticResource TextBoxLabelStyle}"
	         Grid.Column="2" Grid.Row="5" />


        <TextBlock Grid.Column="0" Grid.Row="6"
	                 Text="{x:Static Properties:Resources.MainWindow_DetailsBox_UserName_Text}"
	                 VerticalAlignment="Center" HorizontalAlignment="Right"/>

        <TextBox Text="{Binding Path=LogEntryRows.SelectedLogItem.UserName, Mode=OneWay}"
	               Style="{DynamicResource TextBoxLabelStyle}"
	               Grid.Column="2" Grid.Row="6" />

        <TextBlock Grid.Column="0" Grid.Row="7"
	                 Text="{x:Static Properties:Resources.MainWindow_DetailsBox_Application_Text}"
	                 VerticalAlignment="Center" HorizontalAlignment="Right"/>

        <TextBox Text="{Binding Path=LogEntryRows.SelectedLogItem.App, Mode=OneWay}"
	         Style="{StaticResource TextBoxLabelStyle}"
	         Grid.Column="2" Grid.Row="7" />

        <TextBlock Grid.Column="0" Grid.Row="8"
	                 Text="{x:Static Properties:Resources.MainWindow_DetailsBox_Thread_Text}"
	                 VerticalAlignment="Center" HorizontalAlignment="Right"/>

        <TextBox Text="{Binding Path=LogEntryRows.SelectedLogItem.Thread, Mode=OneWay}"
	         Style="{StaticResource TextBoxLabelStyle}"
	         Grid.Column="2" Grid.Row="8" />
      </Grid>
    </ScrollViewer>
  </Grid>

</UserControl>
